from base_page.base_page import BasePage
import allure


# 登录页
class LoginPage(BasePage):
    url_address = '/login'
    user_box = ("xpath", '//input[@placeholder = "手机／邮箱／个人空间地址"]')
    pwd_box = ("xpath", '//input[@placeholder = "请输入密码"]')
    login_btn = ('xpath', '//input[@value = "登 录"]')

    # 登录
    def login(self, base_url, username, pwd):
        with allure.step('访问gitee登录页面'):
            self.get(base_url + self.url_address)
        with allure.step('输入账户，密码'):
            self.do_sendkeys(self.user_box, username)
            self.do_sendkeys(self.pwd_box, pwd)
        with allure.step('点击登录按钮'):
            self.do_click(self.login_btn)
        with allure.step('检查是否登录成功'):
            assert self.find_el(('xpath', '//div[text() = "我的企业/高校/组织1"]'))
